package com.zmn.oms.manager.config;

import com.zmn.manager.common.utils.IdWorkerUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

/**
 * ID生成器配置
 * @uthor nowind
 * @date 2018/09/11 14:10
 */
//@Configuration
//@ConfigurationProperties(prefix = "operate.idworker")
public class IdWorkerConfig {

    // 数据中心索引
    @Value("${system.idworker.datacenterId}")
    private Integer datacenterId;
    // 服务器索引
    @Value("${system.idworker.workerId}")
    private Integer workerId;


    /**
     * 实例化IdWorkerUtil对象
     */
    @Bean
    public IdWorkerUtil idWorkerUtil() {
        IdWorkerUtil idWorkerUtil = new IdWorkerUtil();
        idWorkerUtil.setDatacenterId(datacenterId);
        idWorkerUtil.setWorkerId(workerId);
        return idWorkerUtil;
    }
}
